package com.chinadci.smartcommunitysystembackstage.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chinadci.smartcommunitysystembackstage.entity.ScsFeedback;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chinadci.smartcommunitysystembackstage.mapper.ScsAdmintypeMapper;
import com.chinadci.smartcommunitysystembackstage.mapper.ScsFeedbackMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
@Service
public class ScsFeedbackService{
    @Autowired
    private ScsFeedbackMapper mapper;

    private Logger log= LoggerFactory.getLogger(this.getClass());

    //显示全部意见反馈
    public List<ScsFeedback> Find(String title){
        log.info("=====显示全部意见反馈");
        List<ScsFeedback> list=null;
        if (title!=null & title!=""){
            list= mapper.Find("%"+title+"%");
        }else{
            list= mapper.Find("%%");
        }
        for (int i = 0; i < list.size(); i++) {
            list.get(i).setName(list.get(i).getUser().get(0).getUName());
        }
        return list;
    }

    //处理意见反馈时查询是否处理过
    public ScsFeedback Finds(int id){
        log.info("=====处理意见反馈时查询是否处理过");
        QueryWrapper<ScsFeedback> qw=new QueryWrapper<>();
        qw.eq("f_id",id);
        return mapper.selectOne(qw);
    }

    //处理意见反馈
    public int Update(int id){
        log.info("=====处理意见反馈");
        QueryWrapper<ScsFeedback> qw=new QueryWrapper<>();
        qw.eq("f_id",id);
        ScsFeedback scs=new ScsFeedback();
        scs.setFState(1);
        return mapper.update(scs,qw);

    }
}
